package com.cai.demo.response;

import lombok.Data;

/**
 * @Title: ResultVO
 * @Author RuoLi
 * @Package com.cai.demo.response
 * @Date 2023/12/14 22:12
 * @description: 返回结果类
 */
@Data
public class ResultVO {
    private int code;
    private Object data;
    private String message;

    public ResultVO(StatusCode statusCode){
        this.code=statusCode.getCode();
    }
    public ResultVO(StatusCode statusCode,Object data){
        this(statusCode);
        this.data=data;
    }
    public ResultVO(StatusCode statusCode,String message){
        this(statusCode);
        this.message=message;
    }
    public static ResultVO ok(Object data){
        return new ResultVO(StatusCode.SUCCESS,data);
    }
    public static ResultVO ok(StatusCode statusCode,Object data){
        return new ResultVO(statusCode,data);
    }
    public static ResultVO ok(){
        return new ResultVO(StatusCode.SUCCESS);
    }

    public static ResultVO fail(Object data){
        return new ResultVO(StatusCode.FAIL,data);
    }
    public static ResultVO fail(){
        return fail(StatusCode.FAIL);
    }
    public static ResultVO fail(StatusCode statusCode,Object data){
        return new ResultVO(statusCode,data);
    }
    public static ResultVO fail(StatusCode statusCode,String message){
        return new ResultVO(statusCode,message);
    }
}
